package ils.domain.model;

import org.hibernate.Session;
import org.hibernate.SessionFactory;

public class BranchRepositoryImpl implements BranchRepository
{
    private SessionFactory sessionFactory;
    @Override
    public Branch getBranch(int branchId)
    {
        Session session = sessionFactory.getCurrentSession();
        return (Branch)session.get(Branch.class, branchId);
    }
    public void setSessionFactory(SessionFactory sessionFactory)
    {
        this.sessionFactory = sessionFactory;
    }

    @Override
    public Branch createBranch(Branch branch) {
        Session session = sessionFactory.getCurrentSession();
        session.save(branch);
        return branch;
    }
}
